This article provides an overview and how-to instructions for removing documents within Ditto.
EVICT
DQL operation.
EVICT
QueryEVICT
operation functions based on a condition, allowing updates to multiple documents simultaneously.
For example, the following snippet, once executed, purges all blue
cars stored in the local Ditto store.
'blue'
cars and you subsequently evict the document with the ID '123456'
that matches the replication query, connected peers reinstate it in your local Ditto store. In other words, without modifying the subscription first, peers in the mesh will replicate the evicted document back to the local peer that evicted it.
Therefore we encourage careful management of subscriptions and evictions. To remove documents with active subscriptions, you must first cancel the relevant subscription before calling the EVICT
method.
mutatedDocumentIDs
method on the result
.
isArchived
field value to true
:
NOT
* *archived, establish a live query where isArchived
is set to false
, and then construct your live query callback.
It’s likely that the isArchived
field is set lazily (i.e. has no value until it is true
), so you can use the coalesce()
function to automatically return false
if the value is unset.
The following code demonstrates searching for documents that are unarchived:
isArchived
field to false
:
EVICT
is not currently available for the Big Peer, although it’s in development. To learn more about removing data from your Big Peer instance, see Writing: HTTP (Legacy).
Consideration | Recommendation |
---|---|
Access frequency and relevance | Ensure memory is allocated only to the most relevant and frequently accessed documents by establishing an automatic process that evicts documents that are: - Accessed less frequently - No longer relevant or needed |
Time-based data | Establish an automatic process to evict or remove time-based data older than a minimum of seven days. (Until expired, time-based data remains accessible by way of local queries.) |
Permanent data loss | If documents are evicted from a local peer and don’t exist on any other peer this data is lost and is unrecoverable. |